package entity;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * Author:shixiaojun@itany.com
 * Date:2022/7/29 9:08
 * Version:1.0-SNAPSHOT
 * Description:
 */
public class User implements Serializable {

    private Integer id;
    // 将后台User对象转换成JSON对象传递到前端时
    // 使用指定的参数loginName代替原有属性名username
    // 传递到前端显示的属性名即为:loginName
//    @JsonProperty("loginName")
    private String username;
    // 将User对象转换成JSON时
    // 会忽略指定的属性
    // 转换成的JSON对象中不包含该属性
//    @JsonIgnore
    private String password;
    private String phone;
    private String address;

    // 对于日期类型的属性转换成JSON对象之后
    // 默认显示的是距离1970年的毫秒数
    // 可以通过注解格式化日期
    // pattern:指定日期格式
    @JsonFormat(pattern = "yyyy年MM月dd日 HH:mm:ss")
    private Date birthday;

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public User() {
    }

    public User(Integer id, String username, String password, String phone, String address) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.phone = phone;
        this.address = address;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", phone='" + phone + '\'' +
                ", address='" + address + '\'' +
                '}';
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }
}
